package com.zmx.piglearn.utils

import java.io.ByteArrayOutputStream
import java.io.InputStream

object StreamTool {
    @JvmStatic
    fun read(input: InputStream): ByteArray {
        val output = ByteArrayOutputStream()
        val buf = ByteArray(1024)
        var len = input.read(buf)
        while (len > 0) {
            output.write(buf, 0, len)
            len = input.read(buf)
        }
        input.close()
        return output.toByteArray()
    }
}